package com.cfl.ticket.controller;

import java.util.ArrayList;
import java.util.Iterator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cfl.model.City;
import com.cfl.model.vo.CityVo;
import com.cfl.ticket.service.CityService;
import com.cfl.utils.AppResponse;
import com.cfl.utils.Constant;

@RestController
@RequestMapping("/city/")
public class CityController {

	@Autowired
	private CityService cityService;
	
	@RequestMapping("findCityByAll")
	@ResponseBody
	public Object findCityByAll(String uid, Integer page) {
		try {
			ArrayList<City> citys = cityService.findCityByAll();
			ArrayList<CityVo> cityVos = new ArrayList<CityVo>();
			for(int i = 0; i < citys.size(); i++)
			{
				cityVos.add(new CityVo(citys.get(i)));
			}
			return new AppResponse(cityVos);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new AppResponse(Constant.code_error, Constant.error);
	}
}
